Skip to content

Make boot-file architecture config distro-aware#788

Merged
vinceaperri merged 7 commits into
mainfrom
user/vinceaperri/per-distro-boot-arch-config
Jun 23, 2026
Merged

Make boot-file architecture config distro-aware#788
vinceaperri merged 7 commits into
mainfrom
user/vinceaperri/per-distro-boot-arch-config

Conversation

@vinceaperri

@vinceaperri vinceaperri commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Boot-file paths and ESP layout are now chosen per distro rather than from a single architecture-only global, and the ISO-to-ISO pipeline detects the distro directly from the initrd.

Previously getBootArchConfig() was a global that only varied by runtime architecture, so every distro received the same Azure-Linux-style ESP layout. This moves the lookup behind the DistroHandler interface so each distro picks its own boot-file layout, and adds a way to identify the distro from an initramfs when no rootfs is mounted.

What changed

  • Added GetBootArchConfig() to the DistroHandler interface. Each distro returns its own per-architecture boot-file map.
  • Azure Linux 4 and Fedora now use a Fedora-style ESP layout (/EFI/BOOT with BOOTX64.EFI / BOOTAA64.EFI). Azure Linux 2/3, ACL, and Ubuntu keep the existing Azure Linux layout.
  • Added targetos.GetInitrdTargetOs() and NewDistroHandlerFromInitrd(). These read an os-release or dracut initrd-release file straight out of the initramfs cpio, auto-detecting gzip and zstd compression from the stream's magic bytes.
  • The ISO-to-ISO path now resolves the distro from the ISO's initrd, choosing the bootstrap per-kernel initrd or the full-OS initrd based on the ISO's initramfs type.
  • Replaced the global getBootArchConfig() with bootArchConfigFromMap() and routed every boot-file lookup (UKI creation, PXE artifacts, ISO artifact store, output artifacts) through the distro handler.

Distro to ESP boot-file layout

Distro Boot-file layout
Azure Linux 2 / 3 Azure Linux
Azure Linux 4 Fedora-style
Fedora Fedora-style
ACL Azure Linux
Ubuntu Azure Linux

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • Code conforms to style guidelines

Comment thread toolkit/tools/internal/targetos/targetos.go Outdated
Comment thread toolkit/tools/internal/initrdutils/initrdread.go
Comment thread toolkit/tools/pkg/imagecustomizerlib/liveosisoutils.go Outdated
Comment thread toolkit/tools/pkg/imagecustomizerlib/distrohandler_fedora.go Outdated
Comment thread toolkit/tools/pkg/imagecustomizerlib/liveospxe.go
Comment thread toolkit/tools/pkg/imagecustomizerlib/liveosisobuilder.go Outdated
Comment thread toolkit/tools/pkg/imagecustomizerlib/liveosisoartifactstore.go
Comment thread toolkit/tools/pkg/imagecustomizerlib/liveosisoartifactstore.go Outdated
Comment thread toolkit/tools/internal/targetos/targetos.go
Comment thread toolkit/tools/pkg/imagecustomizerlib/distrohandler.go Outdated
@vinceaperri vinceaperri force-pushed the user/vinceaperri/per-distro-boot-arch-config branch from f9cf03b to 9fac01c Compare June 22, 2026 17:30
@vinceaperri vinceaperri force-pushed the user/vinceaperri/per-distro-boot-arch-config branch from 9fac01c to 0d24d64 Compare June 22, 2026 21:46
createPXEArtifacts calls distroHandler.GetBootArchConfig() but never received a distroHandler parameter, so the package failed to build with 'undefined: distroHandler'. Add distroHandler as the final parameter and pass it from both call sites in liveosisobuilder.go, which already have a distroHandler in scope.
Move the initrd reading helpers into the initrdutils package.
Drop the sourceLabel parameter from GetInstalledTargetOsFromEnvFields and let callers add context.
Restore the found boolean in GetInstalledTargetOs.
Rename bootloaderFilesConfig to bootloaderFilesConfigAzureLinux.
Resolve the distro from squashfs presence directly instead of via initramfsTypeFromFilesStore.
Add an explicit error check in NewDistroHandlerFromInitrd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants